home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
sorts2
/
sorts.frm
< prev
next >
Wrap
Text File
|
1995-05-08
|
22KB
|
826 lines
VERSION 2.00
Begin Form Sorts
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Double
Caption = "A Program of Sorts"
ClientHeight = 5250
ClientLeft = 1095
ClientTop = 1425
ClientWidth = 6690
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00FFFFFF&
Height = 5655
Icon = SORTS.FRX:0000
Left = 1035
LinkMode = 1 'Source
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5250
ScaleWidth = 6690
Top = 1080
Width = 6810
Begin CommandButton EXIT_PGM
Caption = "EXIT"
Enabled = 0 'False
Height = 855
Left = 5580
TabIndex = 7
Top = 240
Width = 855
End
Begin CommandButton START
Caption = "START"
Height = 855
Left = 4500
TabIndex = 6
Top = 240
Width = 855
End
Begin PictureBox SortPlot
BackColor = &H00FFFFFF&
DrawWidth = 3
ForeColor = &H00000000&
Height = 3996
Left = 240
ScaleHeight = 3960
ScaleWidth = 3960
TabIndex = 0
Top = 240
Width = 3996
End
Begin Label Label5
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "EXIT leaves program, writes result file."
Height = 435
Left = 4440
TabIndex = 11
Top = 1200
Width = 2055
End
Begin Label Label4
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "Results text file will be placed in C:\SORT_LST.TXT"
ForeColor = &H00FF0000&
Height = 615
Left = 4440
TabIndex = 10
Top = 1920
Width = 2055
End
Begin Label Label1
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "Algorithm Run Time"
Height = 255
Left = 4440
TabIndex = 9
Top = 2700
Width = 2055
End
Begin Label text1
Alignment = 2 'Center
BackColor = &H0000FFFF&
Caption = "Algorithm Now Running Shown on Title Bar"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 12
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1275
Left = 4560
TabIndex = 8
Top = 3780
Visible = 0 'False
Width = 1815
End
Begin Label Clock
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "00:00.00"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "Arial"
FontSize = 18
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 435
Left = 4440
TabIndex = 5
Top = 3000
Width = 2055
End
Begin Label Swaps
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "XXX"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "Arial"
FontSize = 13.5
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 315
Left = 2700
TabIndex = 4
Top = 4680
Width = 975
End
Begin Label Iterations
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "XXX"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "Arial"
FontSize = 13.5
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 315
Left = 780
TabIndex = 3
Top = 4680
Width = 975
End
Begin Label Label3
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "Swaps"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "Arial"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 255
Left = 2700
TabIndex = 2
Top = 4320
Width = 975
End
Begin Label Label2
Alignment = 2 'Center
BackColor = &H00C0C0C0&
Caption = "Iterations"
FontBold = -1 'True
FontItalic = 0 'False
FontName = "Arial"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
ForeColor = &H00000000&
Height = 255
Left = 780
TabIndex = 1
Top = 4320
Width = 975
End
End
Dim unit(100) As Integer
Dim StartTime As Double
Dim oldx1 As Integer, oldy1 As Integer, oldx2 As Integer, oldy2 As Integer
Dim newx1 As Integer, newy1 As Integer, newx2 As Integer, newy2 As Integer
Dim Done As Integer, DisplayOn As Integer
Dim comp As Integer, swic As Integer
Dim p(100) As Integer, w(100) As Integer
Dim results(3, 8) As String
Dim base_data(100) As Integer
Dim first_pass As Integer
Sub bsort ()
StartTime = Now
Dim j As Integer, k As Integer, l As Integer, t As Integer
For l = 1 To 100
j = l
For k = j + 1 To 100
comp = comp + 1
If unit(k) <= unit(j) Then
j = k
q% = DoEvents()
End If
Next k
If l <> j Then
swic = swic + 1
t = unit(j)
oldx1 = unit(j)
oldy1 = j
unit(j) = unit(l)
oldx2 = unit(l)
oldy2 = l
newx1 = unit(j)
newy1 = j
unit(l) = t
newx2 = unit(l)
newy2 = l
ShowTime
ShowIter
OverPlot
NewPlot
q% = DoEvents()
End If
Next l
ShowTime
ShowIter
End Sub
Sub dfsort ()
Dim cl As Integer, cr As Integer, k As Integer
Dim min As Integer, max As Integer, umin As Integer, umax As Integer, t As Integer
StartTime = Now
For cl = 1 To 50
cr = 101 - cl
max = unit(cr)
umax = cr
min = unit(cl)
umin = cl
q% = DoEvents()
For k = cr To cl Step -1
comp = comp + 1
q% = DoEvents()
If unit(k) < min Then
min = unit(k)
umin = k
End If
Next k
If unit(cl) > unit(umin) Then
swic = swic + 1
t = unit(cl)
oldx1 = unit(cl)
oldy1 = cl
unit(cl) = unit(umin)